package org.uim.cricket.entities.persist.impl;

import org.uim.cricket.entities.batting.BatsmanStatistics;
import org.uim.cricket.entities.persist.CricketEntityPersistable;

public class XMLBatsmanStatisticsPersist implements CricketEntityPersistable<BatsmanStatistics> {

	private String tagName = "Stats";
	
	@Override
	public String doPersist(BatsmanStatistics object) {
		if (object == null) return "";
		StringBuilder sb = new StringBuilder();

		if (tagName.length() > 0) sb.append("<").append(tagName);

		sb.append(" runs=\"").append(object.getRuns()).append("\"");
		sb.append(" balls=\"").append(object.getBalls()).append("\"");
		sb.append(" minutes=\"").append(object.getMins()).append("\"");
		sb.append(" fours=\"").append(object.getFours()).append("\"");
		sb.append(" sixes=\"").append(object.getSixes()).append("\"");
		
		if (tagName.length() > 0) sb.append(" />");
		return sb.toString();
	}

}
